<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'defaultRoute' => 'index',
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend'],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    'logFile' => '@runtime/logs/'.date("Y-m-d").'.log',
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                "<controller:\w+>/<action:\w+>/<id:\d+>"=>"<controller>/<action>",
                "<controller:\w+>/<action:\w+>"=>"<controller>/<action>",
                //'admin'=>'/adminindex/default/index',
                //'/game/<spelling:\w+>-<gameid:\d+>-<parentgoodsid:\d+>-<goodsid:\d+>' => '/trades/list-trade',  
                '/chat/<chatid:\d+>' => '/chat/default',
            ],
        ],
        
    ],
    'params' => $params,
    'modules' => [
        //首页
        'index' => [
            'class' => 'app\modules\index\Module',
        ],
        //个人中心
        'user' => [
            'class' => 'app\modules\user\Module',
        ],
        //商品分类
        'category' => [
            'class' => 'app\modules\category\Module',
        ],
        'api' => [
            'class' => 'app\modules\api\Module',
        ],
        'chat' => [
            'class' => 'app\modules\chat\Module',
        ],
        'goodslist' => [
            'class' => 'app\modules\goodslist\Module',
        ],
        'goodsdetail' => [
            'class' => 'app\modules\goodsdetail\Module',
        ],
        //购物车
        'cart' => [
            'class' => 'app\modules\cart\Module',
        ],
        //订单
        'order' => [
            'class' => 'app\modules\order\Module',
        ],
    ],
];
